home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NOVA - For the NeXT Workstation
/
NOVA - For the NeXT Workstation.iso
/
Newsletters
/
GEnieUnixNews
/
unxnl-04.92
< prev
next >
Wrap
Text File
|
1992-12-27
|
25KB
|
616 lines
_ _ _ _ _ _
// // //| // // \// N E W S
//_// // |// // /\\ Vol 3, Issue 4 - April 1992
R o u n d T a b l e (tm)
Items of interest to participants of the GEnie Unix RoundTable
The RoundTable SysOps are:
Andy Finkenstadt....ANDY Rick Mobley.........LRARK
Gary Smith..........GARS Brian Riley.........DELPHI
Mike Nolan..........M.NOLAN All Unix SysOps.....UNIXSYSOPS$
We strongly encourage you to contact any or all of us if you have -ANY-
comments or suggestions. This is -YOUR- RoundTable. We are here to make
your participation as pleasant and beneficial as possible.
ED: editor notes - Filling the equation
==
The Unix RoundTable continues to grow into what we have every intent
of becoming the place you think of first when you think of resources
and support for your Unix or Unix-like platform. As you will see in
lead SysOp Andy's notes a help desk is starting in Chatlines, and soon
the much talked about internet gateway will be a reality. The library
continues to build at a very fast pace. We are far from being satsified
that we are fulfilling every need, no matter how hard we try. Part of
the reason we may not be doing so is that we do not see the need.
That's where you come in. You are the reason we exist in the first
place. You are the key element. We urge you to use the FEEDBACK option
in the menu to let us know how we are doing. If you see a problem, don't
assume it will be fixed. Tell us about it. That way you will be sure we
know.
It is also acceptible to let us know if something we are doing pleases
you. This isn't so we will have some warm, fuzzy strokes. It is so we
will know the things we are doing well, and try to emulate them in other
areas, as well.
-- Gary
Lead Sysop Notes Andrew Finkenstadt
================ Chief Sysop
It is now April 1992 and spring has arrived. Spring cleaning is
happening in the Unix bulletin board. New events are occuring,
and ongoing happenings continue.
Two key items are coming up in the near future; the Unix RT hopes
to be your center for information about these products.
* GEnie is implementing an Internet Gateway with
X.400 mail services scheduled later on
* A Unix Help Desk is being established in both the
Unix RT Conference area and the GEnie Chat Lines.
What does internet mail mean for you? GEnie responds to the
widespread request of its members to have some kind of gateway
for mail to the "Net." It means now you can distribute to
persons outside the GEnie mail system your internet address. It
means that you will be able to send mail to just about anyone on
the Net. It means greater connectivity with the world. It may
even mean world peace. We can always hope.
X.400 mail is an international mail standard used for addressing
mail across disparate mail systems. It has a very long method of
addressing which some folks find cumbersome to type. In
addition, there are current limitations in the GE Mail product
limiting addresses to 35 characters. These limitations are being
removed by the GE Mail programmers to allow a better integration
of X.400 with the GE Mail system. GEnie has elected to delay the
release of X.400 connectivity until this integration is
available.
(As of this writing no information about domain name or pricing
is available. Stay tuned. Some information and discussion about
the internet gateway status is available in the GEnie Users'
RoundTable on page 150;1 or 8001;1, category 5, topic 35.)
And beginning April 16, 1992 every Tuesday night in the Unix
Roundtable Conference area (page 160;2 keywork UNIX) and every
Thursday night in the GEnie Chat Lines (page 400;4 keyword CHAT)
a Unix Help Desk will be made available for anyone to ask
Unix-related questions. Once you have entered the chat lines,
choose channel 4 or type /CHA 4 after entering to get to the Help
Desk. Hope to see you there!
In addition to help desks, Chat Lines offers many enticing
features: multi-player games such as Trivia and word games,
interesting conversation and socializing, role playing games with
the Electronic Adventures University, and a full schedule of
events every day. Check out the weekly schedule on page 400,
item 3.
(Side note: your Sysop, Andy, has written several of the games
used in Chat Lines.)
Until next month, it is good to be alive!
Upload Contest Winners for April (ANDY)
================================
And for yet another month, congratulations go to Eric Tremblay
[E.TREMBLAY2] for winning the Unix RT Upload Contest. Frank
Cupo, Eric Trembley, A.Rosenbalm and Erik Uyeda have contributed
greatly toward building a resource of NeXT specific files.
Excellent work, fellas!
And remember: you too can win up to two free days in the Unix
RoundTable on GEnie. For details see the file CONTEST.RULES in
the library, number 2346.
WHO short bios
===
..... our newest SysOp, Mike Nolan
I first became fascinated with computers in 1967, and switched from being
an EE major to a CS major at Northwestern because I preferred programming
computers to designing them. The fascination has never faded.
Since then, I've worked on everything from supercomputers on down, and
moved to Nebraska in 1977 to pick up an MBA and ultimately to go into
contract programming and consulting. My biggest clients are publishers,
and I'm on a national computer advisory committee for the book industry,
chairing a subcommittee on data transmission
I've worked primarily with NCR computers since 1980, and got into Unix in
1989 because I could see that NCR was standardizing on two operating
environments, and didn't want to be just another PC hacker. (Besides which,
I've always tried to make my mark knowing how to make computers do stuff
others can't, and in Unix there are *so* many ways to flaunt the 'rules'.)
I currently write a column on NCR computers for NCR Connection, a trade
paper, and serve on the board of the NCR Unix User Group, where I am
supposed to be the newsletter editor. I'm also somewhat knowledgeable on
uucp, e-mail, and USENET, which mostly means I've struggled with it and
had a bit of success.
FAST and NASTY, DOWN and DIRTY: quick fix scripts that do something
================================
Wrapping Text in VI (Andy)
-------------------
Let's say you have a document which you want to rewrap to
a certain line width - perhaps to center it on an 80 character
line with a 1/2 inch margin. This amounts to a line width
of 70 characters with 5 leading spaces.
Step 1: use the "J" command to combine lines of each paragraph
onto one line.
Step 2: now move to the beginning of the paragraph-on-one-line
and use the next keystrokes to wrap to 70 characters.
Step 3: repeatedly execute "070lbi<return><esc>" until you have
run out of paragraph. This says
0 move to beginning of line
70l move 70 characters to the right
b backwards one word
i insert
<return> split line
<esc> exit insert mode
Step 4: save your work.
Putting the above string into a VI macro is left as an exercise
for the student. An excellent reference is the file vi.macro.Z
available as file number 3020 in the Unix Roundtable.
TUTORIALS:
=========
KSH - Features and extensions
by Brian T. Riley (DELPHI)
Welcome back ladies and gentlemen. This time around we
will continue with a discussion of vi command line editing and
the special characters available in that mode as well as write a
command line shell script. The first thing we need to do is
become familiar with the special characters and features
available when using vi mode with command line editing. These
are;
# - Makes the current line a comment in history file.
= - Lists pathnames that match current word.
* - Replaces current word with matching file names.
~ - Changes case of current letter.
v - Invokes vi program with a file consisting of current line.
Now, to demonstrate these features, we will use them to
write a shell script at the command line. This exercise will also
demonstrate the difference between a normal command prompt, like
MS-DOS, and a UNIX SHELL. A shell, after all, does more than just
execute our commands, it is a programming language all it's own.
But first we need to do a little setup. Our shell script
needs to do something useful. One thing I have always found a
need for is a way to change the permissions of many files in the
current directory without having to do it manually. We will first
create several test files in a temporary directory so that we
will not risk any of our important files. To do this, execute the
following commands;
$cd<cr> # this will take you to your HOME directory.
$mkdir test<cr> # this creates the directory test
$cd test<cr> # this makes test our current directory
$touch atst # this creates the file "atst"
$<ESC>k # press escape and then k to retrieve the last
command for editing
$wrb<cr> # this moves to the second word and replaces "a"
in "atst" with "b" making "btst" then creates it
$<ESC>k # retrieves "touch btst"
$wrc<cr> # makes "touch btst" into "touch ctst" and
creates it
You should now have three files in the test directory.
Execute the following command;
$ls -l<cr>
and you should have something like the following.
-rw-r--r-- 1 brian users 0 Apr 05 08:53 atst
-rw-r--r-- 1 brian users 0 Apr 05 08:54 btst
-rw-r--r-- 1 brian users 0 Apr 05 08:55 ctst
Don't worry if your's is not exactly like mine since we are going
to change things anyway. The part of this display that we want to
change is the first, and most cryptic, part. Namely the
"-rw-r--r--", which tells us that these are files (the first -)
and that the owner (us) has read and write permission (rw-) and
everyone else has only read permission (r--r--).
Now for the script. Type the following commands exactly as shown
and I will explain it afterward.
$for i in `ls ?tst`<cr>
>do echo $i<cr>
>done<cr>
Congratulations! You have just written a command line shell
script! Now lets find out what we did. The first part
for i in `ls ?tst`
starts a loop using the shell command "for" and tells it to
create the environment variable "i" and assign it each of the
file names generated from the output of the command "ls ?tst"
which is substituted for the `ls ?tst`. Be sure you use the `
backquote character which is usually on the same key as the "~"
tilde. Each of the file names are used in turn in the next line
where we tell it what to "do" with it. In this case we just want
the current contents of the variable "i" to be "echo"'d to the
screen. the last line tells the loop that we are "done". Notice
that the last two lines have a ">" instead or our normal prompt?
This is known as the secondary prompt and is defined as the
value of the variable PS2.
Unfortunately, this is not exactly what we wanted to do.
We just did this to make sure we only use the files we want and
to check our script's logic. Now that we know it works we will
change it to do what we want. Do the following;
<ESC>k<cr>
to retrieve our little script. You will notice that even though
we typed three lines, ksh shows us a single line with all of the
commands together, separated by "^J". This is because ksh sees
our script as a single command line instead of three separate
ones. Now that our script is on the command line and we are still
in editing mode press "v" (without the quotes) to load our script
into the full vi program. Now move the cursor to the e in echo
and type "cw" to change this word. Next type in "chmod 777" and
press <ESC>. Your script should now look something like this;
for i in `ls ?tst`
do chmod 777 $i
done
~
~
~
"/tmp/sh95.4" 3 lines, 40 characters
If it does, then type ":wq!" and press return to execute our
modified script. Finally, do an ls -l to display the files again
to see if it was successful. You should see this;
-rwxrwxrwx 1 brian users 0 Apr 05 08:53 atst
-rwxrwxrwx 1 brian users 0 Apr 05 08:54 btst
-rwxrwxrwx 1 brian users 0 Apr 05 08:55 ctst
If not, go back and check for typing errors and try again. After
all that is the benefit of command line recall and editing! :)
You are probably noticing that we did not use the special
characters at the beginning of this article to write our script,
so lets see how they work. Type the following;
$?tst<ESC>=<cr> #this should produce
1) atst
2) btst
3) ctst
$at<ESC>*<cr> #this should produce
$atst
$This is our first shell script<ESC>#<cr>
$cat $HISTFILE<cr> #this should produce
#this is our first shell script
cat $HISTFILE
#as the last two lines of the history file
And finally type;
$touch a<ESC>*<ESC>b~<cr>
Let me explain that one step by step. <ESC>* expands "a" to
"atst", <ESC>b moves the cursor back to the "a" is "atst", "~"
changes the "a" to "A" and the <cr> executes the new command to
create the file Atst in the current directory.
Well, that's all for this time, if I confused anyone I
apologize. If you would like a better explanation, come talk to
me at 9:30 EST on the real time conference where we can interact.
Have a good month! ::smile::
Shells and Subshells, a primer: Mike Nolan (M.NOLAN)
--------------------
As the 'new Sysop on the block', it falls to me to pick a continuing
topic for the newsletter while operating under Harris's Lament: All the
good ones are taken. However, Gary and I have finally settled on a
series of 'reviews' of unix commands which have been ported to MS-DOS.
Watch this space!
However, in the mean time here are some things I've learned about shells
and subshells based on a few Bourne shell scripts I wrote. (With luck,
this won't step on Rick's toes too much, or steal his next column.)
First some basics. The shell interprets commands that are typed in and
either performs them directly or causes them to be performed.
Examples of commands that the Bourne shell performs directly are variable
assignments, 'export', 'echo', and 'cd'. Commands that are actually
executable files, usually in /bin or /usr/bin, include 'ls', and 'cat'.
[It is one of the mysteries of unix, although a lesser mystery, that
while the bourne, c-shell and korn shell all have built-in echo command
processing, there is still an executable file named /bin/echo.]
If the command is a file, a subshell is created, which is a copy of
the shell with the same environment settings. If the command is a
binary of an executable command, like 'ls', it is loaded and then run.
If the command is a text file with additional shell commands, it is a
shell script, and it is also loaded into a subshell which then begins
processing the commands in the file as if they were being typed in.
Because the subshell is only a copy of the shell, and is discarded
after the subshell is finished, variable settings and other changes
made to the subshell's environment do NOT affect the original shell, and
are, in effect, thrown away when the subshell is deleted from memory.
Executing the following shell script would not affect the PATH command in
your shell following completion.
#
# test1.sh, test shell script # 1 for GEnie Unix RT newsletter
#
PATH=/bin:/usr/bin:/usr/mybin
export PATH
#
# end of shell script 'test1.sh'
There is an exception to this, called the 'dot' or '.' command. A
subshell is NOT created when a file is executed from a '.' command.
Thus, typing the command 'test1.sh' would not affect the shell's PATH
variable, but typing the command '. test1.sh' would.
This assumes, of course, that 'test1.sh' has executable permission. If
it does not, it can still be executed by invoking a shell directly,
'/bin/sh test1.sh', but then it will run in a subshell and cannot affect
your shell's environment. You cannot do a '. /bin/sh test1.sh' to get
around this limitation.
Each shell or subshell has its own standard input and standard output.
Within a sequence of commands, commands can be 'stacked' together
with semicolons, where each stack shares a common standard input and output,
or 'piped' together, where each subsequent command receives as its standard
input the standard output of its prececesor. Further, commands which are
placed in parentheses are executed in a subshell.
All this can be used to good effect to control when the standard input is
processed and where the standard output is placed.]
The following three lines will illustrate this simply:
echo 'this is a test'; echo 'this is also a test' | grep -c test
echo 'this is a test'| echo 'this is also a test' | grep -c test
(echo 'this is a test'; echo 'this is also a test') | grep -c test
The first line is executed as follows: 'echo' commands are executed directly
by the shell, so "this is a test" is placed on standard output. The results
of the second echo are to be piped to the grep command, so the echo is
performed in a subshell which places "this is also a test" on its standard
output which is then made the standard input to another subshell, in which
the grep command is performed. You should get the following output:
this is a test
1
The grep command only sees the output from the 2nd echo command, so it
only counts one "test". This line created two subshells.
The second line creates three subshells. One performs the first echo
command, which places "this is a test" on its standard output, which is
then provided as the standard input to another subshell, which does the
2nd echo command. This echo command doesn't utilize any standard input,
so "this is a test" is ignored and "this is also a test" is placed on
standard output and passed along to a third subshell. The third subshell
counts one "test". You should get the following output:
1
(Note that "this is a test" doesn't appear, because it was piped to
the 2nd subshell, which didn't do anything with it.)
The third command starts by creating a subshell. The first echo command
places "this is a test" on standard output, and the second echo command
places "this is also a test" on the SAME standard output. This is then
piped to a second subshell, which sees "test" twice in its standard input.
You should get the following output:
2
This third command only created two subshells, because the two echo commands
shared the same subshell.
Enough theory, on to something that might be practical. I like to keep
track of how much time I spend online with my uucp neighbors, and what
transfer rate I'm achieving, with separate categories for daytime, evening,
and overnight. I wrote the following awk program to process the data in my
xferstats files:
#
# uudaily.awk
#
BEGIN {DATE=xxxxx
printf" Date Cnt Inbound Outbound Total tty07 ttya Speed\n"
}
{
TODAY=substr($3, 2, 8)
if (substr($3,9,1) == ":") TODAY=substr($3,2,7)
if (substr($3,8,1) == ":") TODAY=substr($3,2,6)
if (substr($3,7,1) == ":") TODAY=substr($3,2,5)
len=1
if (substr(TODAY,length(TODAY)-1,1) == "-") len=0
time=substr(TODAY, length(TODAY)-len) + 0
TODAY = substr(TODAY, 1, length(TODAY) - 2 - len)
if (time < 8) TODAY=TODAY " " "NITE"
if (time > 7 && time < 17) TODAY = TODAY " " "DAY "
if (time > 16) TODAY = TODAY " " "EVE "
if (DATE != TODAY)
{
if (DATE != xxxxx)
{
printf "%11s%5d%9d%9d%9d%6.2f%6.2f%8.2f\n", DATE, COUNT, INBOUND,
OUTBOUND, TOTAL, TIME1/3600, TIME2/3600, TOTAL/TIME
}
DATE=TODAY
COUNT=0
TOTAL=0
INBOUND=0
OUTBOUND=0
TIME=0
TIME1=0
TIME2=0
}
if ( $7 != 0)
{
TOTAL=TOTAL+$7
TIME=TIME+$9
if ($6 == "<-") INBOUND=INBOUND+$7
if ($6 == "->") OUTBOUND=OUTBOUND+$7
#
# look for 'a' or '7' to determine if modem on /dev/ttya or /dev/tty07
#
if (substr($5,length($5)-1,1) == "7") TIME1=TIME1+$9
if (substr($5,length($5)-1,1) == "a") TIME2=TIME2+$9
COUNT++
}
}
END
{
printf "%11s%5d%9d%9d%9d%6.2f%6.2f%8.2f\n", DATE, COUNT, INBOUND,
OUTBOUND, TOTAL, TIME1/3600, TIME2/3600, TOTAL/TIME
}
# end of uudaily.awk
So, to run this, all I need to do is supply the xferstats data for each of
my uucp neighbors to the awk program. Hence the following:
#
#uudaily1.stats - summarize modem activity for uucp neighbors
#
XFER=/usr/spool/uucp/.Admin/xferstats
OLD=/usr/spool/uucp/.Old/xferstats
#
echo site1
grep site1 $OLD $XFER |awk -f /usr/local/lib/uudaily.awk -
echo site2
grep site2 $OLD $XFER |awk -f /usr/local/lib/uudaily.awk -
echo site3
grep site3 $OLD $XFER |awk -f /usr/local/lib/uudaily.awk -
echo site4
grep site4 $OLD $XFER |awk -f /usr/local/lib/uudaily.awk -
echo site5
grep site5 $OLD $XFER |awk -f /usr/local/lib/uudaily.awk -
#
# end of uudaily.stats
This shell script creates 11 subshells, two for each grep|awk pair, and
one for the shell script itself.
Well, this is great if run as a cron job, but if I run it interactively
the data for the first couple of sites is likely to scroll off the top of
the page. So, what I do is to divide this up into a series of subshells,
each of which is contained within another subshell, and then pass the
combined standard output to 'more', so that I can page through it
on screen:
#
#uudaily2.stats - summarize modem activity for uucp neighbors, paged
#
XFER=/usr/spool/uucp/.Admin/xferstats
OLD=/usr/spool/uucp/.Old/xferstats
#
(echo site1;
(grep site1 $OLD $XFER |awk -f /usr/local/lib/uudaily.awk - );
echo site2;
(grep site2 $OLD $XFER |awk -f /usr/local/lib/uudaily.awk - );
echo site3;
(grep site3 $OLD $XFER |awk -f /usr/local/lib/uudaily.awk - );
echo site4 ;
(grep site4 $OLD $XFER |awk -f /usr/local/lib/uudaily.awk - );
echo site5;
(grep site5 $OLD $XFER |awk -f /usr/local/lib/uudaily.awk - ) ) | more
#
# end of uudaily.stats
Note that only the output from the grep commands (to select only the
transfer records for that site) is piped to its respective awk program.
This program creates 13 different subshells in all, two for each grep|awk
pair, one for the outer layer of parentheses, one for the more command,
and one for the shells script itself.
I hope this helped you figure out subshells as much as writing the ultimate
shell script helped me figure them out.
***** End of article
---------------
REMINDER - This newsletter is being sent to you 'by request'. If you do
not wish to keep receiving it, e-mail a stop notice to GARS. On the other
hand, we would very much appreciate it if you would pass the word that we
do distribute this item near the tenth (10th) of the month of issue to any-
one on GEnie who requests it.
P L E A S E also remember contributions are most welcome. Please e-mail
items and/or suggestions to GARS.
(EOF)
Trademark and Copyright notices:
Unix is a Trademark of UNIX System Laboratories, Inc.; GEnie, LiveWire, and
RoundTable are Trademarks of General Electric Information Services Company;
Xenix and ms-dos are Trademarks of Microsoft Corporation; NeXT and NeXTstep
are Trademarks of NeXT Computer Systems, Inc., Coherent is a Trademark of
Mark Williams Company, Sun is a Trademark of Sun Microsystems, Inc.
The contents of this newsletter are copyright(c) 1992 and may be copied whole
or in part only if original credit is included. The GEnie UNIX RoundTable is
not affiliated with AT&T or UNIX System Laboratories, Inc.